class Stream:
    element = []

    def __init__(self, element: []):
        self.element = element

    def filter(self, func):
        return Stream(filter(func, self.element))

    def first(self):
        for element in self.element:
            return element
        return None

    def map(self, func):
        ele = []
        for element in self.element:
            ele.append(func(element))
        return Stream(ele)

    def to_map(self, func_key, func_value):
        ele = {}
        for element in self.element:
            ele[func_key(element)] = func_value(element)
        return ele

    def value(self):
        ele = []
        for element in self.element:
            ele.append(element)
        return ele

    def max(self, func=None, key: str = None):
        sorted_item = []
        if func is not None:
            items = []
            for element in self.element:
                items.append({'num': func(element), 'item': element})
            sorted_item = sorted(items, key=lambda x: x["num"])
        elif key is not None:
            sorted_item = sorted(self.element, key=lambda x: x[key])
        return sorted_item[0]
